package com.gxa.meiye.sso.repository;

import com.gxa.meiye.sso.entity.Consumer;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;


public interface UserRepository extends CrudRepository<Consumer,Integer> {
    Consumer findAllByPhoneEquals(String phone);

//    @Modifying
//    @Transactional
//    void deleteByPhoneEquals(String phone);
//    @Modifying
//    @Transactional
//    void deleteByNameEquals(String name);
//
//    @Modifying//增删改操作必须要有这个注解
//    @Transactional // 事务的注解
    @Query(value = "select * from t_consumer WHERE phone = ? order by last_login desc",nativeQuery = true) // nativeQuery 表示自然的sql数据库语句，
    Consumer time(@Param("phone") String phone);


}
